<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="author" content="李军锋">
    <title>恭喜来到死亡空间</title>
    <style>
        .first{
            width: 400px;
            height: 400px;
            /* background-color: gray; */
            /* border: 1px solid orangered; */
            border-radius: 10px;
            margin: 200px auto;
           
        }
        .outline{
            width: 400px;
            height: 100px;
            background-color: orangered;
            border-radius: 10px;
            border: 1px solid orangered;
            margin-top: 200px;
        }
        span{
            border: 1px solid red;
            background-color: red;
            border-radius: 50%;
            line-height: 100px;
             margin-left: 70px; 
            font-size: 30px;
        }
        button{
            width: 100px;
            height: 50px;
            margin-left: 150px;
            bottom: 0;
            
        }
    </style>
</head>
<body>
    <div class="first">
     <div class="outline">
         <span class="shi">1</span>时
         <span class="fen">10</span>分
         <span class="miao">5</span>秒
         
     </div>
   <button type="button" onclick="oppn()">开始倒计时</button>
   </div>
</body>
</html>
<script>
    var shi = document.querySelector('.shi')
    var fen = document.querySelector('.fen')
    var miao = document.querySelector('.miao')
    var button = document.querySelector('button');
    var timer;
    button.onclick = function(){
        var timer = setInterval(function(){
          function miaoX(){
         miao.innerHTML --;
         if (miao.innerHTML == 0) {
             miao.innerHTML = 59;
         }
         if (shi.innerHTML==0,fen.innerHTML==0,miao.innerHTML==0) {
             clearInterval(timer);
         }
       }   
       miaoX(); 
        },1000)
        var timer = setInterval(function(){
         function fenX(){
             if (miao.innerHTML==59) {
                 fen.innerHTML --;
             }
             if (fen.innerHTML == 0) {
             fen.innerHTML = 59; 
         }
            //  if (shi.innerHTML==0) {
            //      clearInterval(timer)
            //  }
         }
        fenX();
        button.innerHTML = '正在倒计时'
        },1000)
        var timer = setInterval(function(){
        function shiX(){
            if (fen.innerHTML==59) {
                shi.innerHTML --;
            }
            if (shi.innerHTML==0) {
                clearInterval(timer);
            }
        }
        shiX();
        },1000)
    }
    
</script>